package com.ww.basic.oop

object TestOption {
  def commentOnPractice(input: String) = {
    // 而不是返回null
    if (input == "test") Some("good") else None
  }

  def main(args: Array[String]): Unit = {
    /**
     * 打印结果
     * input: test comment: good
     * input: hack comment: Found no comments
     */
    for (input <- Set("test", "hack")) {
      val comment = commentOnPractice(input)
      val commentDisplay = comment.getOrElse("Found no comments")
      println(s"input: $input comment: $commentDisplay")
    }
  }
}